﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;

//namespace BL
//{
//    class MessageType
//    {
//        private int messageTypeId;
//        private int prio;
//        private string description;
//        private bool allowDevice;

//        public int MessageTypeId { get; set; }
//        public int Prio { get; set; }
//        public int Description { get; set; }
//        public int AllowDevice { get; set; }

//        public MessageType(int messageTypeId, int prio, string description, bool allowDevice)
//        {
//            this.messageTypeId = messageTypeId;
//            this.prio = prio;
//            this.description = description;
//            this.allowDevice = allowDevice;
//        }

//        public enum TypeOfMessage
//        {
//            Article = 1,
//        };


//        internal static List<MessageType> GetMessageTypesNotSent(int userId, string deviceId, bool isDevice)
//        {

//            dbDataContext db = new dbDataContext();
//            List<MessageType> messageTypesNotSent = new List<MessageType>();

//            if (isDevice)
//            {
//                var query =
//                    from mt in db.tMessageTypes
//                    where mt.messageTypeId == (from cl in db.tTransactionLogs
//                                               where cl.timestamp > (from u in db.tUserDevices
//                                                                     where u.userId == cl.userId
//                                                                     && u.dev.deviceId == deviceId
//                                                                     select u).FirstOrDefault().dev.lastSync
//                                               && cl.deviceId != deviceId
//                                               select cl).FirstOrDefault().messageTypeId
//                    && mt.allowDevice == true
//                    select mt;

//                foreach (var item in query)
//                {
//                    MessageType messagetype = new MessageType(item.messageTypeId, item.prio, item.description, item.allowDevice);
//                    messageTypesNotSent.Add(messagetype);
//                }

//                return messageTypesNotSent;
//            }
//            else
//            {
//                var query =
//                    from mt in db.tMessageTypes
//                    where mt.messageTypeId == (from cl in db.tTransactionLogs
//                                               where cl.timestamp > (from u in db.tUserDevices
//                                                                     where u.userId == cl.userId
//                                                                     && u.dev.deviceId == deviceId
//                                                                     select u).FirstOrDefault().dev.lastSync
//                                               && cl.deviceId != deviceId
//                                               select cl).FirstOrDefault().messageTypeId
//                    select mt;

//                foreach (var item in query)
//                {
//                    MessageType messagetype = new MessageType(item.messageTypeId, item.prio, item.description, item.allowDevice);
//                    messageTypesNotSent.Add(messagetype);
//                }

//                return messageTypesNotSent;
//            }
//        }
//    }
//}
